package com.luchao.springcloud.service;

import com.luchao.springcloudapi.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component //千万不要忘记
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {

    @Override
    public DeptClientService create(Throwable throwable) {
        //重写 服务降级 处理
        return new DeptClientService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept getById(long id) {
                return new Dept().setDeptNo(id).setDname("该id:"+id+"没有对应的数据，客户端提供的服务降级").setDb_Source("no this db");
            }

            @Override
            public List<Dept> getlist() {
                return null;
            }
        };
    }
}
